<%--                                                                       --%>
<%-- Copyright (c) 2004-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import =  "java.util.*,
                    org.apache.commons.beanutils.PropertyUtils,
                    org.apache.struts.validator.DynaValidatorForm,
                    com.broadvision.web.util.ViewDynaBean"
%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<script language="JavaScript">

// Trim whitespace from left and right sides of s.
  function trim(s) {
    return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
  }

//
// Trims leading blanks.
//
function stringLeftTrim(s) {
  return s.replace(/^ +/, "");
}

//
// Trims trailing blanks.
//
function stringRightTrim(s) {
  return s.replace(/ +$/, "");
}

//
// Trims leading and trailing blanks.
//
function stringTrim(s) {
  return stringRightTrim(stringLeftTrim(s));
}

//
// Create a dummy (timestamp) attribute to get around an IE cache problem.
//
function getTimeStamp() {
   var now = new Date;
   var timestamp = '' + now.getYear() + now.getMonth() + now.getDate() + now.getHours() + now.getMinutes() + now.getSeconds() + now.getMilliseconds();
   return timestamp;
}

function searchUserPopup(popupUrl, parentFormName, parentFieldName) {
  var thisForm = document.forms[parentFormName];
  var windowName = parentFormName + parentFieldName;
  var windowFeatures = 'width=700,height=600,scrollbars=yes,resizable=yes';
  var urlDummy="<%=request.getContextPath()%>"+"/mt/user/userPopupHelper.jsp?parentFormName="+parentFormName+"&parentFieldName="+parentFieldName;
  var popupWindow=window.open(urlDummy,windowName,windowFeatures);
  if ( popupWindow != null) {
    if( popupWindow.opener == null) {
      popupWindow.opener = self;
    }
  }
  popupWindow.focus();
}

function setUserAliasNew(formName, fieldValue, firstName, lastName,
fullName, userAlias) {
  // this page does not have any hidden fields that rely on the popup,
  // we do not need a refresh url.
  var refreshUrl = null;
  setUserFindFieldValue(refreshUrl, formName, fieldValue, firstName,
lastName, fullName, userAlias);
}
  
function setUserFindFieldValue(refreshUrl, formName, fieldValue,
firstName, lastName, fullName, userAlias) {

  var thisForm = document.forms[formName];
  var elements = thisForm.elements;
  var numElements = elements.length;

  if (thisForm.useFullName.value == "true") {
    thisForm.fullNameTo.value = fullName;
  }
  else {
    thisForm.firstNameTo.value = firstName;
    thisForm.lastNameTo.value = lastName;
  }
  thisForm.userAliasTo.value = userAlias;
}


function doCancel(theForm) {
  //var ok = confirm('<bean:message key="confirmCancel"  bundle="bp.messages"/>');
  var ok = true;
  if (ok && theForm != null) {
    if (theForm.origin.value == "taskList") {
      theForm.action = '<html:rewrite page="/bp/taskList.do"/>';
    }
    else {
      theForm.action = '<html:rewrite page="/bp/userSearch.do"/>';
    }
    theForm.submit();
  }
  return false;
}
 
function doPrevious(theForm) {
  if (theForm.origin.value == "taskList") {
    theForm.action = '<html:rewrite page="/bp/taskList.do"/>';
  }
  else {
    theForm.action = '<html:rewrite page="/bp/reassignTasksSelect.do"/>';
  }
  theForm.submit();
  return false;
}

</script>

<% 
  java.util.HashMap map = new java.util.HashMap();

  DynaValidatorForm reassignTasksForm = (DynaValidatorForm) request.getAttribute("reassignTasksForm");
  map.put("userId", PropertyUtils.getSimpleProperty(reassignTasksForm, "userId"));
  map.put("userNameFrom", PropertyUtils.getSimpleProperty(reassignTasksForm, "userNameFrom"));

  map.put("formAction", "to");

  map.put("firstNameFrom", request.getParameter("firstNameFrom"));
  map.put("lastNameFrom", request.getParameter("lastNameFrom"));
  map.put("fullNameFrom", request.getParameter("fullNameFrom"));
  map.put("userAliasFrom", request.getParameter("userAliasFrom"));

  map.put("firstNameTo", request.getParameter("firstNameTo"));
  map.put("lastNameTo", request.getParameter("lastNameTo"));
  map.put("fullNameTo", request.getParameter("fullNameTo"));
  map.put("userAliasTo", request.getParameter("userAliasTo"));

  map.put("origin", request.getParameter("origin"));
  map.put("useFullName", request.getParameter("useFullName"));

  pageContext.setAttribute("pagetabParam", map, PageContext.PAGE_SCOPE);
%>


<!-- Zone 5 starts here.  -->

<html:form action="/bp/reassignTasksTo.do">

<html:hidden property="userId" />
<html:hidden property="firstNameFrom" />
<html:hidden property="lastNameFrom" />
<html:hidden property="fullNameFrom" />
<html:hidden property="userAliasFrom" />
<html:hidden property="useFullName" />
<html:hidden property="userNameFrom" />
<html:hidden property="formAction" value="save" />
<html:hidden property="origin" />

<%
  Integer[] tasks = (Integer[]) PropertyUtils.getSimpleProperty(reassignTasksForm, "taskIds");

  for (int i = 0; i < tasks.length; i++) {
    String taskId = tasks[i].toString();
%>

<input type="hidden" name="taskIds" value="<%= taskId %>"/>

<%
  }
%>

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message key="bp.package.contentArea" bundle="bp.messages"/>">
  <tr>
    <td valign="top" width="100%">		    

      <div class="pageTitle">
          <bean:message key="bp.user.reassignTasks" bundle="bp.messages"/>
      </div>

      <!-- pageTab -->
      <div class="errorMessage"><html:errors bundle="bp.messages"/></div>
      <%@include file="/mc/common/pagetab.jsp" %>
      <!-- end of PageTab -->			

      <div class="pageSubtitle">
        <span class="left">
          <bean:message key="bp.user.reassignTasks.selectDelegate" bundle="bp.messages"/>
        </span>
        <span class="right">&nbsp;</span>
      </div> 
			
		
      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Select ??">
        <tr> 

          <td class="label" width="10%" nowrap>
             <bean:message key="bp.user.reassignTasks.from" bundle="bp.messages"/>:
          </td>
          <td class="labelField" width="10%" nowrap>
            <bean:write name="reassignTasksForm" property="userNameFrom"/>
          </td>
          <td class="labelField" width="10%" nowrap>&nbsp;</td>
          <td class="labelField" width="10%" nowrap>&nbsp;</td>
          <td class="labelField" width="60%" nowrap>&nbsp;</td>
        </tr>
        <tr>
          <td class="label" width="10%" nowrap><bean:message key="bp.user.reassignTasks.to" bundle="bp.messages"/>:</td>

          <logic:equal name="reassignTasksForm" property="useFullName" value="false">
            <td class="labelField" width="10%" nowrap>
              <html:text name="reassignTasksForm" property="firstNameTo" size="20" maxlength="80" />
                <br><i>(<bean:message key="bp.user.label.firstName" bundle="bp.messages"/>)</i>
            </td>
            <td class="labelField" width="10%" nowrap>
	      <html:text name="reassignTasksForm" property="lastNameTo" size="20" maxlength="80" />
              <br><i>(<bean:message key="bp.user.label.lastName" bundle="bp.messages"/>)</i> 
            </td>
          </logic:equal>
          
          <logic:equal name="reassignTasksForm" property="useFullName" value="true">
            <td class="labelField" width="20%" nowrap>
	      <html:text name="reassignTasksForm" property="fullNameTo" size="20" maxlength="80" />
              <br><i>(<bean:message key="bp.user.label.fullName" bundle="bp.messages"/>)</i>
            </td>
          </logic:equal>

          <td class="labelField" width="10%" nowrap>
	      <html:text name="reassignTasksForm" property="userAliasTo" size="20" maxlength="80" />
              <br><i>(<bean:message key="bp.user.label.loginId" bundle="bp.messages"/>)</i>
          </td>
          <td class="labelField" width="60%" nowrap>
            <input type="button" name="browse" class="pageButton"
              onclick="JavaScript:searchUserPopup('<html:rewrite page="/mt/userSearchPopup.do"/>', 'reassignTasksForm','to');" value='<bean:message key="button.browse" bundle="bp.messages"/>'>
          </td>
        </tr>
      </table>

       <div class="pageButtonWrap" align="right">

         <html:button property="cancelBtn" styleClass="pageButton"
onclick="return doCancel(this.form);">
           <bean:message key="button.cancel" bundle="bp.messages"/>
         </html:button>
         &nbsp;
         <html:button property="previousBtn" styleClass="pageButton"
onclick="return doPrevious(this.form);">
           <bean:message key="button.previous"  bundle="bp.messages"/>
         </html:button>

        <html:submit property="submitBtn" styleClass="pageButton"><bean:message key="button.save" bundle="bp.messages"/></html:submit>
       </div>
			
    </td>
  </tr>
</table>

<!--end zone 5 content here -->

</html:form>		  
